package com.canaan.business.controller.pc.basic;

import java.util.List;

import com.canaan.business.domain.basic.WmsCodeRuleDetail;
import com.canaan.business.service.basic.IWmsCodeRuleDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.canaan.common.annotation.Log;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.enums.BusinessType;
import com.canaan.common.utils.poi.ExcelUtil;
import com.canaan.common.core.page.TableDataInfo;

/**
 * 条码规则明细Controller
 *
 * @author ruoyi
 * @date 2023-01-29
 */
@Api(tags = "条码规则明细")
@RestController
@RequestMapping("/system/detail")
public class WmsCodeRuleDetailController extends BaseController {
    @Autowired
    private IWmsCodeRuleDetailService wmsCodeRuleDetailService;

    /**
     * 查询条码规则明细列表
     */
    @ApiOperation(value = "查询条码规则明细列表")
    @GetMapping("/list")
    public TableDataInfo list(WmsCodeRuleDetail wmsCodeRuleDetail) {
        startPage();
        List<WmsCodeRuleDetail> list = wmsCodeRuleDetailService.selectWmsCodeRuleDetailList(wmsCodeRuleDetail);
        return getDataTable(list);
    }

    /**
     * 导出条码规则明细列表
     */
    @ApiOperation(value = "导出条码规则明细列表")
    @Log(title = "条码规则明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsCodeRuleDetail wmsCodeRuleDetail) {
        List<WmsCodeRuleDetail> list = wmsCodeRuleDetailService.selectWmsCodeRuleDetailList(wmsCodeRuleDetail);
        ExcelUtil<WmsCodeRuleDetail> util = new ExcelUtil<WmsCodeRuleDetail>(WmsCodeRuleDetail.class);
        util.exportExcel(response, list, "条码规则明细数据");
    }

    /**
     * 获取条码规则明细详细信息
     */
    @ApiOperation(value = "获取条码规则明细详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(wmsCodeRuleDetailService.selectWmsCodeRuleDetailById(id));
    }

    /**
     * 新增条码规则明细
     */
    @ApiOperation(value = "新增条码规则明细")
    @Log(title = "条码规则明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsCodeRuleDetail wmsCodeRuleDetail) {
        return toAjax(wmsCodeRuleDetailService.insertWmsCodeRuleDetail(wmsCodeRuleDetail));
    }

    /**
     * 修改条码规则明细
     */
    @ApiOperation(value = "修改条码规则明细")
    @Log(title = "条码规则明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsCodeRuleDetail wmsCodeRuleDetail) {
        return toAjax(wmsCodeRuleDetailService.updateWmsCodeRuleDetail(wmsCodeRuleDetail));
    }

    /**
     * 删除条码规则明细
     */
    @ApiOperation(value = "删除条码规则明细")
    @Log(title = "条码规则明细", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(wmsCodeRuleDetailService.deleteWmsCodeRuleDetailByIds(ids));
    }
}
